﻿<UserControl x:Class="TVersiPlay.MainMenu.Views.MainMenuView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:fluid="clr-namespace:FluidKit.Controls;assembly=FluidKit"             
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:ac="clr-namespace:TVersiPlay.Common;assembly=TVersiPlay.Common"
             Loaded="UserControl_Loaded"
             mc:Ignorable="d"             
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>

        <LinearGradientBrush x:Key="ReflectionBrush"
                             StartPoint="0,0"
                             EndPoint="0,1">
            <GradientStop Offset="0"
                          Color="#7F000000" />
            <GradientStop Offset=".5"
                          Color="Transparent" />
        </LinearGradientBrush>

        <ImageBrush Opacity="5" x:Key="MusicBackground" ImageSource="/TVersiPlay.MainMenu;component/BackGrounds/Music_Names.png" Stretch="Fill"/>
        <ImageBrush Opacity="5" x:Key="MovieBackground" ImageSource="/TVersiPlay.MainMenu;component/BackGrounds/Movie_Names.png" Stretch="Fill"/>
        <ImageBrush Opacity="5" x:Key="ImageBackground" ImageSource="/TVersiPlay.MainMenu;component/BackGrounds/Image_Names.png" Stretch="Fill"/>
        <ImageBrush Opacity="5" x:Key="PremiumBackground" ImageSource="/TVersiPlay.MainMenu;component/BackGrounds/Premium_Content.png" Stretch="UniformToFill"/>

        <RadialGradientBrush x:Key="EFBackground" >
            <GradientStop Color="#FF2F1C00"/>
            <GradientStop Color="Black" Offset="1"/>
        </RadialGradientBrush>

        <DataTemplate x:Key="MenuTemplate_Reflection">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="0.5*" />
                    <RowDefinition Height="0.5*" />
                </Grid.RowDefinitions>

                <Border x:Name="ElementVisual"
                        BorderThickness="2"
                        BorderBrush="LightYellow"
                        Background="Black"
                        Padding="2">
                    <Image Source="{Binding Path=MenuImage}"
                           Stretch="Uniform" />
                </Border>
                <Rectangle OpacityMask="{StaticResource ReflectionBrush}"
                           Grid.Row="1"
                           Height="{Binding ActualHeight, ElementName=ElementVisual}">
                    <Rectangle.Fill>
                        <VisualBrush Visual="{Binding ElementName=ElementVisual}">
                            <VisualBrush.RelativeTransform>
                                <ScaleTransform ScaleX="1"
                                                ScaleY="-1"
                                                CenterX="0.5"
                                                CenterY="0.5" />
                            </VisualBrush.RelativeTransform>
                        </VisualBrush>
                    </Rectangle.Fill>
                </Rectangle>
            </Grid>
        </DataTemplate>

    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />

        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.5*" />
            <ColumnDefinition Width="0.5*" />
        </Grid.ColumnDefinitions>


        <fluid:ElementFlow x:Name="_elementFlow"
                              Grid.Row="1"
                              Grid.RowSpan="2"
                              Grid.Column="0"
                              Grid.ColumnSpan="2"                        
                              ItemTemplate="{DynamicResource MenuTemplate_Reflection}" 
                              TiltAngle="0"
                              ItemGap="1.5"
                              FrontItemGap="3"
                              PopoutDistance="-1"
                              ElementWidth="200"                              
                              ElementHeight="200"                              
                              ItemsSource="{Binding Path=MyItems}">

            <fluid:ElementFlow.Layout>
                <fluid:Carousel/>
            </fluid:ElementFlow.Layout>

            <i:Interaction.Triggers>
                <i:EventTrigger EventName="PopoutItemIsSelected">
                    <ac:CommandAction Command="{Binding SelectedMenuPressed}" CommandParameter="{Binding SelectedMenuIndex}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>

            <fluid:ElementFlow.Camera>
                <PerspectiveCamera FieldOfView="40"
                                   Position="0,.7,4"
                                   LookDirection="0,-.5,-4"
                                   UpDirection="0,3,0"/>
            </fluid:ElementFlow.Camera>

        </fluid:ElementFlow>

       
        <Grid Margin="2" Grid.Row="0" Grid.ColumnSpan="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="250"/>
                <RowDefinition Height="*"/>       
            </Grid.RowDefinitions>         
            
            <Label Grid.Row="0">
                <Label.Style>
                    <Style TargetType="{x:Type Label}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Path=SelectedMenuIndex}" Value="0">
                                <Setter Property="Background" Value="{StaticResource MusicBackground}"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Path=SelectedMenuIndex}" Value="1">
                                <Setter Property="Background" Value="{StaticResource MovieBackground}"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Path=SelectedMenuIndex}" Value="2">
                                <Setter Property="Background" Value="{StaticResource ImageBackground}"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Path=SelectedMenuIndex}" Value="3">
                                <Setter Property="Background" Value="{StaticResource PremiumBackground}"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Label.Style>
            </Label>
            <TextBlock TextAlignment="Center" Grid.Row="1" 
                       Foreground="PaleGoldenrod"
                       Margin="0,5,0,0"
                       HorizontalAlignment="Stretch"                                        
                       FontSize="14"
                       Text="{Binding Path=SelectedMenuDescription}">         
            </TextBlock>
        </Grid>
        

    </Grid>
</UserControl>
